package com.joshondesign.sdljava.demo;

import com.joshondesign.sdljava.SDL;
import com.joshondesign.sdljava.SDLUtil;
import com.joshondesign.sdljava.SDL_Surface;
import com.joshondesign.sdljava.gfx.*;
import com.sun.xml.internal.ws.api.PropertySet;

import java.util.Enumeration;
import java.util.Properties;


public class ShapesTest implements SDLUtil.InitCallback {
    public static void main(String ... args) {
        SDLUtil.init(new ShapesTest());
    }

    public void callback() throws Exception {
        Util.standard_init();
        Util.p("os.name= " + System.getProperty("os.name"));
        Util.p("java.vm.vendor = " + System.getProperty("java.vm.vendor"));
        Util.p("java.vm.name = " + System.getProperty("java.vm.name"));
        Util.p("os.arch = " + System.getProperty("os.arch"));
        //Util.p(System.getProperty("os.name"));
        Properties props = System.getProperties();
        Util.p("entryset.size = " + props.entrySet().size());
        Util.p("props size = " + props.size());
        Util.p("props value size = " + props.values().size());
        //Util.p("spn = " + props.stringPropertyNames().size());
        Util.p("elements = " + props.elements().hasMoreElements());
        Util.p("pnames = " + props.propertyNames().hasMoreElements());
        Enumeration en = props.keys();
        Util.p("enumerating through the System properties: " + en.hasMoreElements());
        while(en.hasMoreElements()) {
            Object o = en.nextElement();
            Util.p(o.toString() + " = " + props.getProperty(o.toString()));
        }
        SDL_Surface surface = null;
        if("arm".equals(System.getProperty("os.arch"))) {
            surface = Util.createFullscreenWindow();
        } else {
            surface = Util.createResizableWindow(800, 600);
        }
        Util.dump(SDL.SDL_GetVideoInfo());
        final Scene scene = new Scene(surface);
        scene.setBackgroundFill(SColor.WHITE);
        Layer layer = new Layer(surface.getFormat());
        scene.add(layer);

        layer.add(new Node() {
            @Override
            public void draw(GFX gfx) {
                gfx.setPaint(SColor.BLACK);
                gfx.drawLine(0,0,50,50);
                gfx.drawLine(0,10,50,30);
                gfx.drawCircle(gfx, 100,100,20);
                gfx.drawEllipse(50,50, 50,100);
                gfx.drawRoundRect(500,200, 100, 50, 19);
            }
        });

        scene.start();

    }

}
